package com.yqy.config;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@ApiModel("方法统一返回对象")
public class ResponseData<T> implements Serializable {
    private static final long serialVersionUID = -8782333365744933352L;
    @ApiModelProperty("状态码")
    private int code = 200;
    @ApiModelProperty("状态描述信息")
    private String message = "";
    @ApiModelProperty("返回数据体")
    private T data;

    public static <T> ResponseData<T> ok() {
        return new ResponseData();
    }

    public static <T> ResponseData<T> ok(T data) {
        return new ResponseData(data);
    }

    public static <T> ResponseData<T> fail(String message, int code) {
        return new ResponseData(message, code);
    }


    public ResponseData(T data) {
        this.data = data;
    }

    public ResponseData(String message) {
        this.message = message;
    }

    public ResponseData(String message, int code) {
        this.message = message;
        this.code = code;
    }

    public ResponseData() {
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }
}

